#ifndef ENVMAPGENERATOR_H
#define ENVMAPGENERATOR_H

#include <Ogre.h>
#include "Component.h"

using namespace Ogre;

class EnvMapGenerator :
			public Component,
			
			public Ogre::FrameListener,
			public RenderTargetListener
			
//			public WorkQueue::RequestHandler,
//			public WorkQueue::ResponseHandler
	{
	public:
		EnvMapGenerator(Root*, SceneManager*);
		EnvMapGenerator(Root*, SceneManager*, ComponentContainer* c);
		~EnvMapGenerator();

		void setup();
		void clean();
		
		bool frameStarted(const FrameEvent& evt);
		bool frameRenderingQueued(const FrameEvent& evt) {	return true; }
		bool frameEnded(const FrameEvent& evt) { return true; }

		virtual void preRenderTargetUpdate(const RenderTargetEvent& evt);
		virtual void postRenderTargetUpdate(const RenderTargetEvent& evt);
		
//		virtual Response* handleRequest(const Request* req, const WorkQueue* srcQ) = 0;
		
		SceneNode* mNode;
		Ogre::String mTexName;

protected:
		Ogre::Timer* mTimer;
		TexturePtr	mTex;
		
		SceneManager* mSceneMgr;
		Camera* mCamera;

		RenderTarget* mTargets[6];
		RenderTarget* mSphereTarget;
		RenderTarget* mPlaneTarget;
		
		SceneNode* mSphereNode;
		Entity* mSphereEnt;
		
		Real dt;
		
		uint16 mWorkQueueChannel;
		
//	Texture* mTex;
	};

#endif // ENVMAPGENERATOR_H
